﻿using System.Web;
using Toolkit.Web.Infastructure;
using System.Web.UI;

namespace Toolkit.Web.ViewComponents
{
    public static class ViewComponentFactoryExtensions
    {
        public static ViewComponentFactory Toolkit()
        {
            return new ViewComponentFactory(new ViewComponentWriter());
        }

        public static ViewComponentFactory Toolkit(this HttpContext httpContext)
        {
            return new ViewComponentFactory(new ViewComponentWriter(value => httpContext.Response.Write(value)));
        }

        public static ViewComponentFactory Toolkit(this HttpResponse httpResponse)
        {
            return new ViewComponentFactory(new ViewComponentWriter(value => httpResponse.Write(value)));
        }

        public static ViewComponentFactory Toolkit(this Page page)
        {
            return page.Response.Toolkit();
        }

        public static ViewComponentFactory Toolkit(this UserControl control)
        {
            return control.Response.Toolkit();
        }
    }
}
